/*
 * @Author: jianghaiyang807
 * @Date:   2016-10-27
 */

import Vue from 'vue'
import VueRouter from 'vue-router'
import PreviewProtocol from 'views/common/PreviewProtocol'
import qwzl from 'views/qwzl'

Vue.use(VueRouter)
const router = new VueRouter({
  mode: 'hash',   //hash、abstract、history
  routes: [
    {
      path: '/',
      component: qwzl.QwzlIntroduce,
      redirect: '/qwzl/index'
    },
    {
      path: '/protocol/:file/:backPath',
      name: 'protocol',
      component: PreviewProtocol,
      meta: {
        show: true,
        title: '预览协议'
      }
    },
    {
      path: '/qwzl',
      name: 'Qwzl',
      component: qwzl.main,
      children: [
        {
          path: 'index',
          component: qwzl.introduce,
          meta: {
            show: false,
            backPath: '/qwzl/index',
            title: '千万尊旅'
          }
        },
        {
          path: 'insure',
          component: qwzl.insure,
          meta: {
            show: true,
            backPath: '/qwzl/index',
            title: '平安千万尊旅意外伤害保险-投保页'
          }
        },
        {
          path: 'result',
          component: qwzl.result,
          meta: {
            show: true,
            hideBackPath: true,
            title: '承保结果'
          }
        }
      ]
    }
  ]
})
// 全局钩子
router.beforeEach((to, from, next) => {
  if (to.matched.some(record => record.meta.notToTop)) {
    window.scrollTo(0, 0)
  }
  next()
})


export default router
